//
//  UILale+Extension.swift
//  sinaWeibo
//
//  Created by LSY on 15/12/21.
//  Copyright © 2015年 lsy. All rights reserved.
//

import UIKit

extension UILabel {


    convenience init (title:String,color:UIColor,fontSize:CGFloat,margin:CGFloat = 0){
    
        self.init()
        
        text = title
        //    设置颜色
        textColor = color
        
        //    设置字号
        font = UIFont.systemFontOfSize(fontSize)
        //    设置居中
        textAlignment = .Center
        
        numberOfLines = 0
        if margin > 0 {
            //设置最大显示的宽度
            preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * margin
            textAlignment = .Left
        }

        //    自动适应大小
        sizeToFit()
    }

}